﻿using Assets.Scripts.Game.GameObj;
using Assets.Scripts.Game.Manager;
using Assets.Scripts.Game.ResourceConfig;
using UnityEngine;
using System.Collections;
using UnityEditor;

public class Main : MonoBehaviour {

    
    MainPlayer _mainPerson;
    Map _map;
	// Use this for initialization
	void Start () {
     //   _map = new Map();
      //  _map.LoadFromFile(@"file://D:\workspace\Doc_sgqz\trunk\GameRes\Map\BigMap\20100001\");
      //  transform.Translate(new Vector3(_map._center.x, _map._center.y, 0));
  
        Debug.Log("i am here");


       // ioo.resourceManager.CodeLoadAsset("girl", "girl", new ResourceManager.LoadAssetHandle(OnLoadAssetOK));

	    //ResourceLoadConfigManager.Instance().Init();
        LuaConfigMgr.Instance().Init();
	    

	    // display.transform.parent = ioo.guiCamera;
	    ////display.transform.Translate(0,-2,0);

	    //display.transform.localScale = new Vector3(0.8f,0.8f);

	}

    private void OnLoadAssetOK(GameObject obj)
    {
        GameObject go = Instantiate(obj) as GameObject;
        go.name = "girl";        
        
    }

  
    private GameObject getObjectByName(string name)
    {
        GameObject[] objs = FindObjectsOfType(typeof(GameObject)) as GameObject[];
        foreach (GameObject obj in objs)
        {
            if (obj.name == name)
            {
                return obj;
            }
        }
        return null;
    }
	
	// Update is called once per frame
	void Update () {

        if (Input.GetKey(KeyCode.W))
        {
            //_mainPerson.transform.Translate(new Vector3(0.1f, 0, 0));
    
                // animationClip = 
            //Animation anim = _mainPerson.GetComponent<Animation>();
            //anim.
          
        }

        if (Input.GetMouseButtonDown(1))
        {            
            Vector3 mScreenPos = Input.mousePosition;
            Position mScreenWPos = _map.ScreenToLogicPos(mScreenPos);
          //  _mainPerson.Player.Do_Move(mScreenWPos);
            //Debug.Log(DirectionHelper.TwoPosition(_mainPerson.Player.Pos, mScreenWPos));
        }

   //     _mainPerson.Player.Update();

       


        //transform.Translate(_mainPerson.Player.GameObject.transform.position - transform.position);
	
	}
}
